package com.itheima.Zixi4.ZuoYe.Zuoye4;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.Scanner;

public class Zuoye4 {
    public static void main(String[] args) throws Exception {
        try(
        FileInputStream fis = new FileInputStream("D:\\a\\XIXNI.txt");
        FileOutputStream fos = new FileOutputStream("D:\\a\\XIXNI.txt", true);){
            Scanner sc = new Scanner(System .in);
            System.out.println("请输入学生姓名以及年纪，中间用，分隔");
            String s = sc.next();
            fos.write(s.getBytes());
            fos.write("\n".getBytes());
            fos.flush();
            System.out.println("写入成功");
            System.out.println("关闭成功");
        }
        catch (Exception e){
            e.printStackTrace();
        }finally {
            System.out.println("程序结束");
        }
    }
}
